import { createBrowserRouter } from 'react-router-dom';
import { MainLayout } from '../layouts/MainLayout';
import { Login } from '@/pages/login';
import { ArticleList } from '@/pages/article-list';
import { ArticleEdit } from '@/pages/article-edit';
import { AuthRoute } from './AuthRoute';

export const router = createBrowserRouter([
    {
        path: '/login',
        element: <Login />,
    },
    {
        path: '/',
        element: (
            <AuthRoute>
                <MainLayout />
            </AuthRoute>
        ),
        children: [
            {
                index: true,
                element: <ArticleList />,
            },
            {
                path: 'create',
                element: <ArticleEdit />,
            },
            {
                path: 'edit/:id',
                element: <ArticleEdit />,
            },
        ],
    },
]);